package com.example;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author Liuqz
 * @date 2018/11/15 21:08
 */
public class createStream {


    public static void main(String[] args) {
//        createStreamFromCollection().forEach(System.out::print);
//        createStreamFromValues().forEach(System.out::print);


        createStreamFromArrays();
    }

    private static Stream<String> createStreamFromCollection() {
        List<String> result = Arrays.asList("hello", "alex", "wangwenjun", "world", "stream");
        return result.stream();
    }

    private static Stream<String> createStreamFromValues() {
        return Stream.of("hello", "alex", "wangwenjun", "world", "stream");
    }

    private static Stream<String> createStreamFromArrays() {
        String[] strings = {"hello", "alex", "wangwenjun", "world", "stream"};
        return Arrays.stream(strings);
    }

    private static Stream<Integer> createStreamFromIterator() {
        Stream<Integer> stream = Stream.iterate(0, n -> n + 2);
        return stream;
    }
}
